//package com.platform.mall.security.core.userdetails.user;
//
//import com.platform.mall.common.result.ResultCode;
//import com.platform.mall.mapper.SysUserMapper;
//import com.platform.mall.model.dto.AuthUserDTO;
//import com.platform.mall.service.ISysUserService;
//import lombok.RequiredArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.security.authentication.AccountExpiredException;
//import org.springframework.security.authentication.DisabledException;
//import org.springframework.security.authentication.LockedException;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.core.userdetails.UsernameNotFoundException;
//import org.springframework.stereotype.Service;
//
///**
// * 系统用户体系业务类
// *
// * @author <a href="mailto:xianrui0365@163.com">haoxr</a>
// */
//@Service("sysUserDetailsService")
//@Slf4j
//@RequiredArgsConstructor
//public class SysUserDetailsServiceImpl implements UserDetailsService {
//
//    private final SysUserMapper userMapper;
//
//    @Override
//    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
//        SysUserDetails userDetails = null;
//        AuthUserDTO user = userMapper.getAuthInfoByUsername(username);
//        if (null != user) {
//            userDetails = new SysUserDetails(user);
//        }
//        if (userDetails == null) {
//            throw new UsernameNotFoundException(ResultCode.USER_NOT_EXIST.getMsg());
//        } else if (!userDetails.isEnabled()) {
//            throw new DisabledException("该账户已被禁用!");
//        } else if (!userDetails.isAccountNonLocked()) {
//            throw new LockedException("该账号已被锁定!");
//        } else if (!userDetails.isAccountNonExpired()) {
//            throw new AccountExpiredException("该账号已过期!");
//        }
//        return userDetails;
//    }
//
//}
